﻿@using ZBJF.Warranty.WebProvider
@{
    ViewBag.Title = "Index";
}
@section Header{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
}
<form id="searchForm" class="breadcrumb form-search">
    <div>
        <label>信息收集项目分类：</label>
        @Html.DropDownList("InfoCollectCategoryID", ConvertToSelector.Instance.InfoCollectItemCategoryToSelectList())
        <label>关键词：</label>
        <input id="Keyword" name="Keyword" class="input-medium" placeholder="请输入搜索关键词" type="text" value="" maxlength="50" />
        <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
    </div>
</form>
<div class="table-responsive dataTables_wrapper">
    <table id="dataTable" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th width="20"><input type="checkbox" id="ckbAll" /></th>
                <th width="20">序号</th>
                <th width="100">信息收集项名称</th>
                <th width="100">所属分类名称</th>
            </tr>
        </thead>
    </table>
</div>
<div class="form-actions control-group align-center">
    <input id="btnConfirm" class="btn btn-primary Edit-R" type="submit" value="提交">
    <input id="btnClose" class="btn" type="button"  value="关闭" onclick="parent.layer.closeAll()">
</div>
@section scripts{
    @Scripts.Render("~/Bundles/Chosen")
    @Styles.Render("~/Content/Chosen")
    <script type="text/javascript">
        $(function () {
            $("#InfoCollectCategoryID").chosen();
            var objTable = $("#dataTable")
                .dataTable({
                    fnDrawCallback: function () {
                        ControlPermissionOperate();
                    },
                    "sAjaxSource": "/InfoCollectItem",
                    aoColumns: [
                        {
                            "mData": null,
                            "bSortable": false,
                            "fnRender": function (nRow) {
                                return "<input type='checkbox' name='checkList' class='CheckBoxItem' value='" + nRow.aData.ID + "'>";
                            }
                        },
                        {
                            "mData": null, "fnRender": function (nRow) {
                                return nRow.iDataRow + 1;
                            }
                        },
                        {
                            "mData": "InfoCollectItemName"
                        },
                        { "mData": "InfoCollectCategoryName" }
                    ]
                });
            initCheckBoxItem("dataTable", "@(Request["multiselect"] == "true")");

            function getSelectedItems() {
                var nTrs = objTable.fnGetNodes();//fnGetNodes获取表格所有行，nTrs[i]表示第i行tr对象
                var selectedItems = [];
                for (var i = 0; i < nTrs.length; i++) {
                    if ($(nTrs[i]).hasClass('selected')) {
                        selectedItems.push(objTable.fnGetData(nTrs[i]));
                    }
                }
                return selectedItems;
            }

            $("#btnConfirm").click(function () {
                var items = getSelectedItems();
                if (!items || items == "" || items.length < 1) {
                    layer.alert("请选择信息收集项目！");
                    return;
                }
                parent.setSelectItem(items);
                parent.layer.closeAll();
            });
        });
        function search() {
            /*给查询对象赋值*/
            queryParamList.Keyword = ($("#Keyword").val()).trim();
            queryParamList.InfoCollectCategoryID = ($("#InfoCollectCategoryID").val()).trim();
            $("#dataTable").dataTable().fnDraw();
        }

    </script>
}

